]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
iconGrid: Add alignment parameter
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 14 Oct 2010 12:27:22 +0000 (14:27 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 14 Oct 2010 15:41:54 +0000 (17:41 +0200)
Currently the grid's content is centered, which is not appropriate
for all use cases. Add an optional parameter to control the alignment.

https://bugzilla.gnome.org/show_bug.cgi?id=632147

js/ui/iconGrid.js

index 05abe1bdb094bda97bce53f6af6fdf9737a55bcd..3625316e8c47506619bda880d67988a9de3a7807 100644 (file)
@@ -135,9 +135,12 @@ function IconGrid(params) {
 
 IconGrid.prototype = {
     _init: function(params) {
-        params = Params.parse(params, { rowLimit: null, columnLimit: null });
+        params = Params.parse(params, { rowLimit: null,
+                                        columnLimit: null,
+                                        xAlign: St.Align.MIDDLE });
         this._rowLimit = params.rowLimit;
         this._colLimit = params.columnLimit;
+        this._xAlign = params.xAlign;
 
         this.actor = new St.BoxLayout({ style_class: 'icon-grid',
                                         vertical: true });
@@ -189,9 +192,19 @@ IconGrid.prototype = {
 
         let [nColumns, usedWidth] = this._computeLayout(availWidth);
 
-        let overallPaddingX = Math.floor((availWidth - usedWidth) / 2);
+        let leftPadding;
+        switch(this._xAlign) {
+            case St.Align.START:
+                leftPadding = 0;
+                break;
+            case St.Align.MIDDLE:
+                leftPadding = Math.floor((availWidth - usedWidth) / 2);
+                break;
+            case St.Align.END:
+                leftPadding = availWidth - usedWidth;
+        }
 
-        let x = box.x1 + overallPaddingX;
+        let x = box.x1 + leftPadding;
         let y = box.y1;
         let columnIndex = 0;
         let rowIndex = 0;
@@ -231,7 +244,7 @@ IconGrid.prototype = {
 
             if (columnIndex == 0) {
                 y += this._item_size + this._spacing;
-                x = box.x1 + overallPaddingX;
+                x = box.x1 + leftPadding;
             } else {
                 x += this._item_size + this._spacing;
             }